package com.web.netty.domain;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: wws
 * describe:
 */
public class ReJoinPayload implements Serializable {
    private byte type;
    private byte[] appEui;
    private byte[] devEui;
    private byte[] devNonce;
    private byte[] mic;

    public ReJoinPayload() {
    }



    public ReJoinPayload(byte type, byte[] appEui, byte[] devEui, byte[] devNonce, byte[] mic) {
        this.type = type;
        this.appEui = appEui;
        this.devEui = devEui;
        this.devNonce = devNonce;
        this.mic = mic;
    }

    public ReJoinPayload(byte[] data) {

        this.type = data[0];
        this.appEui = Arrays.copyOfRange(data, 1, 9);
        this.devEui = Arrays.copyOfRange(data, 9, 17);
        this.devNonce = Arrays.copyOfRange(data, 17, 19);
        this.mic = Arrays.copyOfRange(data, 19, 23);
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public byte[] getAppEui() {
        return appEui;
    }

    public void setAppEui(byte[] appEui) {
        this.appEui = appEui;
    }

    public byte[] getDevEui() {
        return devEui;
    }

    public void setDevEui(byte[] devEui) {
        this.devEui = devEui;
    }

    public byte[] getDevNonce() {
        return devNonce;
    }

    public void setDevNonce(byte[] devNonce) {
        this.devNonce = devNonce;
    }

    public byte[] getMic() {
        return mic;
    }

    public void setMic(byte[] mic) {
        this.mic = mic;
    }

    @Override
    public String toString() {
        return "ReJoinData{" +
                "type=" + type +
                ", appEui=" + Arrays.toString(appEui) +
                ", devEui=" + Arrays.toString(devEui) +
                ", devNonce=" + Arrays.toString(devNonce) +
                ", mic=" + Arrays.toString(mic) +
                '}';
    }

}
